Conditional code such as traces are often used in applications and other programs. These conditional segments of code can even be used in operating system kernels. Conditional code segments are only executed when associated conditions are met. Often a variable is associated with the conditional code segments. The conditional code segments are executed when the variable is set or has a specific value.
During the execution of the program that contains conditional code, upon encountering the conditional code, the associated variable is checked to determine whether it is set. If the variable is set then the conditional code is executed. If the variable is not set, then the conditional code is not executed. However, in either case, the conditional code is loaded into the instruction cache and creates other additional overhead in the execution of the program.
Traces are an example of a type of conditional code that is frequently used in programs. Traces are used for diagnostic purposes to identify and track the condition of the program in which the trace resides during its execution. These traces are enabled during diagnostic checks on a program or during debugging operations. In normal operation, these traces are not executed. The more traces that can be inserted into a program, the greater the level of detail and the higher the level of granularity of information about the program that can be obtained in the diagnostic and debugging processes. However, the more traces and associated trace code that is utilized in a program, the lower the processor efficiency due to the overhead in the execution of the program caused by loading the trace code into the processor and the space the trace code occupies in caches.